package com.brunobas.pontosmart.baseadapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.brunobas.pontosmart.R;
import com.brunobas.pontosmart.utils.Util;

public class MenuPontoSmartBaseAdapter extends AbstractBaseAdapter {

	private Integer [] listaOpcoes;
	private String [] nomeOpcoes;
	
	public MenuPontoSmartBaseAdapter(Context context, Integer [] lista, String [] nomeOpcoes) {
		super(context);
		
		this.listaOpcoes = lista;
		this.nomeOpcoes = nomeOpcoes;
	}

	@Override
	public int getCount() {

		return this.listaOpcoes.length;
	}

	@Override
	public Object getItem(int position) {

		return this.listaOpcoes[ position ];
	}

	@Override
	public long getItemId(int position) {

		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		LayoutInflater inflater = Util.getLayoutInflater(this.context);
	 
			View gridView;
			
			if (convertView == null) {
				
				gridView = new View(this.context);
				
				gridView = inflater.inflate(R.layout.layout_images_grid_menu_pontosmart, null);
				
				ImageView imageView = (ImageView) gridView.findViewById(R.id.imgsOpcoes);
				
				imageView.setImageResource(this.listaOpcoes[ position ]);
				
				TextView textView = (TextView) gridView.findViewById(R.id.textViewDescricaoOpcao);
				
				textView.setText(nomeOpcoes[ position ]);
				
			} else {
				
				gridView = (View) convertView;
			}
		
		
		return gridView;
	}

}
